#coding=utf-8
from utility import *
from parser import *
from pyExcelerator import *

import time

soup = get_soup('http://www.technica.com.cy/')

links = get_links(soup)
wb = Workbook()
sheet = wb.add_sheet('link')
for i in range(len(links)):
    sheet.write(i, 0, links[i][0])
    sheet.write(i, 1, links[i][1])
wb.save('./link.xls')

products = []
for l in links:
    link = l[1]
    products.extend(get_a_category(link))
    
    time.sleep(1)
    print l[0],len(products)
    
wb = Workbook()
sheet = wb.add_sheet('products')
for i in range( len(products) ):
    sheet.write(i, 0, products[i][0])
    sheet.write(i, 1, products[i][1])
    sheet.write(i, 2, products[i][2])
wb.save('./products.xls')    

